namespace Webinator.DomTraversal
{
    using Webinator.Enums;
    using Webinator.MultipleAttribute;

    /// <summary>
    /// Defines a node.
    /// </summary>
    internal class XpathNode
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        public XpathNode()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="nodeIs">The attribute to look for.</param>
        public XpathNode(NodeIs nodeIs)
        {
            NodeIs = nodeIs;
            DefinedAttributes = null;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="nodeIs">The attribute to look for.</param>
        /// <param name="value">The value.</param>
        public XpathNode(NodeIs nodeIs, string value)
        {
            NodeIs = nodeIs;
            DefinedAttributes = ByAttribute.Any(value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="nodeIs">The attribute to look for.</param>
        /// <param name="value">The value.</param>
        /// <param name="contains">Indicates whether the attribute value should be an exact match.</param>
        public XpathNode(NodeIs nodeIs, string value, bool contains)
        {
            NodeIs = nodeIs;
            DefinedAttributes = ByAttribute.Any(value, contains);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="nodeIs">The attribute to look for.</param>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        public XpathNode(NodeIs nodeIs, DefinedAttributes definedAttributes)
        {
            NodeIs = nodeIs;
            DefinedAttributes = definedAttributes;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="customNode">The attribute to look for.</param>
        public XpathNode(string customNode)
        {
            NodeIs = NodeIs.Custom;
            CustomNode = customNode;
            DefinedAttributes = null;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="customNode">The attribute to look for.</param>
        /// <param name="value">The value.</param>
        public XpathNode(string customNode, string value)
        {
            NodeIs = NodeIs.Custom;
            CustomNode = customNode;
            DefinedAttributes = ByAttribute.Any(value);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="customNode">The attribute to look for.</param>
        /// <param name="value">The value.</param>
        /// <param name="contains">Indicates whether the attribute value should be an exact match.</param>
        public XpathNode(string customNode, string value, bool contains)
        {
            NodeIs = NodeIs.Custom;
            CustomNode = customNode;
            DefinedAttributes = ByAttribute.Any(value, contains);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="XpathNode"/> class.
        /// </summary>
        /// <param name="customNode">The attribute to look for.</param>
        /// <param name="definedAttributes">The attribute(s) to use when locating the element(s).</param>
        public XpathNode(string customNode, DefinedAttributes definedAttributes)
        {
            NodeIs = NodeIs.Custom;
            CustomNode = customNode;
            DefinedAttributes = definedAttributes;
        }

        /// <summary>
        /// Gets or sets the node to look for.
        /// </summary>
        public NodeIs NodeIs { get; set; }

        /// <summary>
        /// Gets or sets the custom node.
        /// </summary>
        public string CustomNode { get; set; }

        /// <summary>
        /// Gets or sets the node attributes.
        /// </summary>
        public DefinedAttributes DefinedAttributes { get; set; }
    }
}
